package com.zhb.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhb.cloud.base.BaseController;
import com.zhb.cloud.client.UserClient;
import com.zhb.cloud.utils.ResultVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @ClassName: UserController
 * @Description:测试
 * @author: zhb1316783262@163.com
 * @date: 2019年4月17日下午4:37:37
 *
 */
@RestController
@RequestMapping("user")
@Api("用户中心API")
public class UserController extends BaseController {

	@Autowired
	private UserClient userClient;

	@GetMapping(value = "userInfo")
	@ApiOperation(value = "根据用户名查询用户信息")
	@ApiImplicitParams({
			@ApiImplicitParam(paramType = "query", name = "userName", dataType = "string", value = "用户名") })
	public ResultVo<?> userInfo(String userName) {
		return userClient.findByUserName(userName);
	}

	@GetMapping(value = "findByUserNameAndPhone")
	@ApiOperation(value = "根据用户名和手机号查询用户信息")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "userName", dataType = "string", value = "用户名"),
			@ApiImplicitParam(paramType = "query", name = "phone", dataType = "string", value = "手机号") })
	public ResultVo<?> findByUserNameAndPhone(String userName, String phone) {
		return userClient.findByUserNameAndPhone(userName, phone);
	}

	@GetMapping(value = "findById")
	@ApiOperation(value = "根据用户Id查询用户信息")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "id", dataType = "string", value = "id值") })
	public ResultVo<?> findById(int id) {
		return userClient.findById(id);
	}
}
